-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Forbid ShallowInitBox after box deref elaboration. #147687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Forbid ShallowInitBox after box deref elaboration.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (472fdbf): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -2.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 474.707s -> 474.445s (-0.06%) |
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in compiler/rustc_codegen_ssa |
r? @nnethercote rustbot has assigned @nnethercote. Use |
|
||
#[macro_export] | ||
macro_rules! indexvec { | ||
($expr:expr; $n:expr) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also have IndexVec::from_elem_n
. Probably doesn't hurt to have this as well, just thought I'd mention it.
I don't see anything objectionable here but my knowledge of this part of the code is very thin, so it's a very shallow approval, and I have zero sense of whether this approach is better or worse than the alternatives mentioned in the PR description. So I would be happy if someone who knows more (@bjorn3? @WaffleLapkin?) wants to weigh in. |
☔ The latest upstream changes (presumably #147654) made this pull request unmergeable. Please resolve the merge conflicts. |
8bfd97c
to
23999f0
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
@@ -1,26 +1,26 @@ | |||
//! This pass transforms derefs of Box into a deref of the pointer inside Box. | |||
//! | |||
//! Box is not actually a pointer so it is incorrect to dereference it directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can you update docs here to also mention removal of ShallowBoxInit
?
if self.body.phase >= MirPhase::Runtime(RuntimePhase::Initial) { | ||
self.fail(location, format!("ShallowInitBox after ElaborateBoxDerefs")) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: Why isn't this at the start of the block?
MIR currently contains a
ShallowInitBox
rvalue. Its principal usage is to allow for in-place initialization of boxes. Having it is necessary for drop elaboration to be correct with that in-place initialization.As part of analysis->runtime MIR lowering, we canonicalize deref of boxes to use the stored raw pointer. But we did not perform the same change to the construction of the box.
This PR replaces
ShallowInitBox
by the pointer manipulation it represents.Alternatives:
ShallowInitBox
and implementBox
in-place initialization differently;ElaborateBoxDeref
pass and keep dereferencingBox
in runtime MIR.